<template>
  <vue-ueditor-wrap
  @input="getValue"
  :value="value" :config="myConfig"></vue-ueditor-wrap>
</template>

<script>
import VueUeditorWrap from 'vue-ueditor-wrap'
import '../../../public/UE/ueditor.config.js'

export default {
  props: ['value'],
  data () {
    return {
      // 编辑器设置
      myConfig: {
        autoHeightEnabled: false,
        initialFrameHeight: 400,
        initialFrameWidth: '100%',
        // serverUrl: 'http://35.201.165.105:8000/controller.php',
        serverUrl: process.env.VUE_APP_BASE_URL + `/upload/ueditor/image`,
        // serverUrl: '/text' + `/ueditor/config`,
        UEDITOR_HOME_URL: process.env.VUE_APP_URL_PATH + '/UE/',
        // UEDITOR_HOME_URL: '/UE/',
        // 是否浮动工具栏
        autoFloatEnabled: false,
        // 不显示底部元素路径
        // elementPathEnabled: false
        toolbars: [
          [
            'fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|', 'insertimage', 'insertcode', '|',
            'horizontal', 'date', 'time', 'spechars', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',
            'print', 'preview', 'searchreplace', 'drafts', 'help'
          ]
        ]
      }
    }
  },
  mounted() {
    // console.log(UE);

    // window.UE.Editor.prototype.getActionUrl = function(action){
		// 	if (action == 'uploadimage' || action== 'uploadscrawl' || action == 'uploadimage') {
		// 		return common.FILE_URL + '/upload'
		// 	} else if(action =='uploadvideo') {

		// 	} else if(action == 'listimage'){

		// 	} else{
		// 	}
		// }
  },
  methods: {
    getValue (val) {
      this.$emit('input', val)
    }
  },
  components: {
    VueUeditorWrap
  }
}
</script>
